﻿using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using NetTaste;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System.Data;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text.RegularExpressions;
using VM.BLL.Menu;
using VM.Common.DataUntil;
using VM.Common.EntityEnum;
using VM.Common.Result;
using VM.Entity.EntityDto.Menu;
using VM.Entity.EntityMap.DataBase;
using VM.Entity.EntityMap.Member;
using VM.Entity.EntityMap.Menu;
using VM.Entity.EntityMap.MsgCode;
using VM.Entity.EntityMap.Region;
using VM.Entity.EntityMap.Token;
using VM.Entity.EntityMap.Topic;
using VM.IBLL.Common;
using VM.IBLL.Member;
using VM.IBLL.Menu;
using VM.IBLL.Token;
using VM.IBLL.Topic;
using VM.IDAL;
using VM.IDAL.Common;


using static Dm.net.buffer.ByteArrayBuffer;

namespace VM.BLL.Common
{
    public class CommonBLL : BaseBLL, ICommonBLL
    {

        private readonly ISqlSuggarDAL _ISqlSuggarDAL;
        private readonly IMenuBLL _IMenuBLL;
        private readonly ICommonDAL _ICommonDAL;
        public CommonBLL(ISqlSugarClient client, ISqlSuggarDAL sqlSuggarDAL, IMenuBLL iMenuBLL, ICommonDAL commonDAL)
        {
            _ISqlSuggarDAL = sqlSuggarDAL;
            _IMenuBLL = iMenuBLL;
            _ICommonDAL = commonDAL;
        }

        public ApiResult commonDelById(int userId, int menuId, int id, int billStatus = 999)
        {

            ApiResult res = new ApiResult();

            ApiDataResult<menuInfoDetailDto> MenuRes = _IMenuBLL.getMenuInfoById(userId, menuId);
            if (MenuRes.code == 200)
            {
                string sqlTableName = MenuRes.data.sqlTableName;
                int Res = _ICommonDAL.MaskDelete(id, userId, billStatus, sqlTableName);
                res.code = 200;
                res.msg = $@"删除成功{Res}条数据";
            }
            else
            {
                res.code = MenuRes.code;
                res.msg = "错误：在后台寻找菜单类时出错，" + MenuRes.msg;
            }
            return res;

        }
    }
}




